import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/page/layout/layout.vue'

const routes: Array<RouteRecordRaw> = [{
    path: '/',
    redirect: '/index',
}, {
    path: '/',
    name: 'layout',
    component: Layout, 
    children: [{
        path: 'index',
        name: 'index',
        component: () => import('@/page/main-app/index/index.vue'),
    }, {
        path: 'about',
        name: 'about',
        component: () => import('@/page/main-app/about/about.vue'),
    }, {
        path: 'setting',
        name: 'setting',
        component: () => import('@/page/main-app/setting/setting.vue'),
    }, {
        path: 'user-info',
        name: 'userInfo',
        component: () => import('@/page/main-app/user-info/user-info.vue'),
    }, {
        path: 'vue-app/index',
        name: 'vueApp',
        component: () => import('@/page/micro-app/micro-app.vue'),
    }, {
        path: 'react-app/index',
        name: 'reactApp',
        component: () => import('@/page/react-app/react-app.vue'),
    }]
}]

const router = createRouter({
    history: createWebHistory(),
    routes,
})
router.beforeEach((to, from, next) => {
    console.log('main-app router history', history)
    // console.log('main-app router beforeEach from', from)
    // console.log('main-app router beforeEach to', to)
    next()
})
export default router
